package com.unicom.projt;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.Gravity;
import android.widget.Toast;
import com.unicom.projt.db.Account;
import com.unicom.projt.db.DB;
import com.unicom.projt.db.DBConfig;
import com.unicom.projt.http.HttpConnection;

/**
 * Created by IntelliJ IDEA.
 * User: Lee
 * Date: 12-1-10
 * Time: 下午4:01
 */
public class SplashActivity extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash_activity);
        DB db=DB.getInstance(this).open();
//        Account account=new Account();
//        account.id=1;
//        account.password="a";
//        account.phoneNumber="a";
//        account.remember="1";
//        db.insertAccount(account);
        Account a=db.queryAccountByPhoneNumber("a");
        Log.d(Const.TAG + "query :", a.password);
        db.close();
        HttpConnection.assetManager=getAssets();
        new Handler().postDelayed(new Runnable() {
            public void run() {
                Intent mainIntent = new Intent(SplashActivity.this,
                        InputPhoneNumberPage.class);
                SplashActivity.this.startActivity(mainIntent);
                SplashActivity.this.finish();
            }
        }, 2000);
    }
    @Override
    protected void onResume() {
        showLoading();
        super.onResume();
        onBackPressed();
    }

    private void showLoading(){
        int duration = Toast.LENGTH_SHORT;
        CharSequence sc = "正在启动沃快充....";
        Toast toast =Toast.makeText(this,sc,duration);
        toast.getView().setBackgroundDrawable(getResources().getDrawable(R.drawable.splash));
        toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
        toast.show();
    }
}
